#include <dirent.h>
#include <cstring>
#include <cstddef>
#include <vector>
#include "generaldef.h"

#ifndef DIRCLASS_H
#define DIRCLASS_H 1

using namespace std;

/* XXX: should I seperate the two classes or just combine them like this? */
class dir_t{
	private:
		DIR *_nowdir;
		char _dirpath[PATH_LEN];
		vector<dirent*> _files, _subdirs;
	public:
		dir_t(){ _nowdir=NULL; _files.clear(); _subdirs.clear(); memset(_dirpath,0,sizeof(_dirpath)); }
		bool open(char*);
		void scanentries(char exclist[][NAME_LEN], int exccnt);
		char* findcorr(const char *);
		int filecnt(){ return _files.size(); }
		int subdircnt(){ return _subdirs.size(); }
		void select(char[][NAME_LEN], int);
		const char* name(){ return _dirpath; }
		const dirent* file(int x){ return _files[x]; }
		const dirent* subdir(int x){ return _subdirs[x]; }
		const DIR* dirptr(){ return _nowdir; }
		void close(){ closedir(_nowdir); }
};

#endif /* DIRCLASS_H */
